<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../style.css" type="text/css" media="screen">
<link rel="stylesheet" href="../../../../print.css" type="text/css" media="print">
<meta content="TaskController,com.developmentarc.core.controllers.TaskController,activeTasks,notReadyQueue,taskQueue,activeTaskLimit,addTask,applyOverrides,handleTaskEvent,next" name="keywords">
<title>com.developmentarc.core.controllers.TaskController</title>
</head>
<body>
<script type="text/javascript" language="javascript" src="../../../../asdoc.js"></script><script type="text/javascript" language="javascript" src="../../../../cookies.js"></script><script type="text/javascript" language="javascript">
<!--
				asdocTitle = 'TaskController - DevelopmentArc Core API Documentation';
				var baseRef = '../../../../';
				window.onload = configPage;
			--></script>
<table style="display:none" id="titleTable" cellspacing="0" cellpadding="0" class="titleTable">
<tr>
<td align="left" class="titleTableTitle">DevelopmentArc Core API</td><td align="right" class="titleTableTopNav"><a onclick="loadClassListFrame('../../../../all-classes.html')" href="../../../../package-summary.html">All&nbsp;Packages</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('../../../../all-classes.html')" href="../../../../class-summary.html">All&nbsp;Classes</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('../../../../index-list.html')" href="../../../../all-index-A.html">Index</a>&nbsp;|&nbsp;<a href="../../../../index.html?com/developmentarc/framework/controllers/TaskController.html&amp;com/developmentarc/framework/controllers/class-list.html" id="framesLink1">Frames</a><a onclick="parent.location=document.location" href="" style="display:none" id="noFramesLink1">No&nbsp;Frames</a></td><td rowspan="3" align="right" class="titleTableLogo"><img alt="Adobe Logo" title="Adobe Logo" class="logoImage" src="../../../../images/logo.jpg"></td>
</tr>
<tr class="titleTableRow2">
<td align="left" id="subTitle" class="titleTableSubTitle">Class&nbsp;TaskController</td><td align="right" id="subNav" class="titleTableSubNav"><a href="#propertySummary">Properties</a>&nbsp;| <a href="#methodSummary">Methods</a></td>
</tr>
<tr class="titleTableRow3">
<td colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript" language="javascript">
<!--
if (!isEclipse() || window.name != ECLIPSE_FRAME_NAME) {titleBar_setSubTitle("Class TaskController"); titleBar_setSubNav(false,true,false,false,false,false,true,false,false,false,false,false,false,false);}
--></script>
<div class="MainContent">
<table cellspacing="0" cellpadding="0" class="classHeaderTable">
<tr>
<td class="classHeaderTableLabel">Package</td><td><a onclick="javascript:loadClassListFrame('class-list.html')" href="package-detail.html">com.developmentarc.core.controllers</a></td>
</tr>
<tr>
<td class="classHeaderTableLabel">Class</td><td class="classSignature">public class TaskController</td>
</tr>
<tr>
<td class="classHeaderTableLabel">Inheritance</td><td class="inheritanceList">TaskController <img class="inheritArrow" alt="Inheritance" title="Inheritance" src="../../../../images/inherit-arrow.gif"> flash.events.EventDispatcher</td>
</tr>
</table>
<p></p>
  The TaskController class is the main manager of the task system framework. This class is 
  responsible for managing current and new tasks in a task system. The class is used as an 
  instance to allow for multiple task to run in the same application.
  
  <p>The TaskController, by default, is not a singleton and the goal of the framework is to 
  allow multiple Task systems to be running in any given application. For example, one task 
  system can be created to manage server requests while another can be used to control internal 
  business operations. To create multiple systems, simply create multiple instances of the 
  TaskController. </p>
  
  <p>To use the TaskController as a singleton, utilize the SingletonFactory utility class within
  the DevelopmentArc Core library.</p>
  
  <p>The controller starts a set of tasks based on the active task limit set on the controller. 
  By default 2 tasks can be concurrently active within the controller, however this is configurable 
  in the task controller instance. When a task is complete the controller will remove the task 
  from the active list and start the next one in the queue, if any. </p>
  
  The TaskController is also responsible for managing overrides. When a task is added to the controller, 
  the tasks overrides are applied removing any existing tasks from the queue that matches an override. 
  Overrides do pertain to tasks that are currently active, those will be canceled and removed from the queue. 
  Next the task is added to the internal priority queue in the proper order. </p>
  
  <p></p>
<br>
<hr>
</div>
<a name="propertySummary"></a>
<div class="summarySection">
<div class="summaryTableTitle">Public Properties</div>
<table id="summaryTableProperty" class="summaryTable " cellpadding="3" cellspacing="0">
<tr>
<th>&nbsp;</th><th colspan="2">Property</th><th class="summaryTableOwnerCol">Defined&nbsp;by</th>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><a class="signatureLink" href="#activeTaskLimit">activeTaskLimit</a> : uint<div class="summaryTableDescription">
   Contains the number of tasks that can be run at the same time.</div>
</td><td class="summaryTableOwnerCol">TaskController</td>
</tr>
</table>
</div>
<a name="protectedPropertySummary"></a>
<div class="summarySection">
<div class="summaryTableTitle">Protected Properties</div>
<table id="summaryTableProtectedProperty" class="summaryTable " cellpadding="3" cellspacing="0">
<tr>
<th>&nbsp;</th><th colspan="2">Property</th><th class="summaryTableOwnerCol">Defined&nbsp;by</th>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><a class="signatureLink" href="#activeTasks">activeTasks</a> : <a href="../datastructures/utils/HashTable.html">HashTable</a>
<div class="summaryTableDescription">
   Stores the active Tasks and TaskGroups that are have been started by the controller.</div>
</td><td class="summaryTableOwnerCol">TaskController</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><a class="signatureLink" href="#notReadyQueue">notReadyQueue</a> : <a href="../datastructures/utils/HashTable.html">HashTable</a>
<div class="summaryTableDescription">
   Stores ITasks that returned false for the ready value when attempted to be started by the controller.</div>
</td><td class="summaryTableOwnerCol">TaskController</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><a class="signatureLink" href="#taskQueue">taskQueue</a> : <a href="../datastructures/utils/PriorityQueue.html">PriorityQueue</a>
<div class="summaryTableDescription">
   Stores the current Tasks and TaskGroups within the TaskController.</div>
</td><td class="summaryTableOwnerCol">TaskController</td>
</tr>
</table>
</div>
<a name="methodSummary"></a>
<div class="summarySection">
<div class="summaryTableTitle">Public Methods</div>
<table id="summaryTableMethod" class="summaryTable " cellpadding="3" cellspacing="0">
<tr>
<th>&nbsp;</th><th colspan="2">Method</th><th class="summaryTableOwnerCol">Defined&nbsp;by</th>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#TaskController()">TaskController</a>()</div>
<div class="summaryTableDescription">
   Constructor.</div>
</td><td class="summaryTableOwnerCol">TaskController</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#addTask()">addTask</a>(task:<a href="interfaces/ITask.html">ITask</a>):void</div>
<div class="summaryTableDescription">
   When an ITask (task, task group, etc.) is ready to be added to the controller this
   method is called.</div>
</td><td class="summaryTableOwnerCol">TaskController</td>
</tr>
</table>
</div>
<a name="protectedMethodSummary"></a>
<div class="summarySection">
<div class="summaryTableTitle">Protected Methods</div>
<table id="summaryTableProtectedMethod" class="summaryTable " cellpadding="3" cellspacing="0">
<tr>
<th>&nbsp;</th><th colspan="2">Method</th><th class="summaryTableOwnerCol">Defined&nbsp;by</th>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#applyOverrides()">applyOverrides</a>(newTask:<a href="interfaces/ITask.html">ITask</a>):Boolean</div>
<div class="summaryTableDescription">
   <p>
   Used to find and remove any tasks in the current
   queue that are overriden by a new task that has been
   added to the controller.</div>
</td><td class="summaryTableOwnerCol">TaskController</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#handleTaskEvent()">handleTaskEvent</a>(event:<a href="events/TaskEvent.html">TaskEvent</a>):void</div>
<div class="summaryTableDescription">
   Called when a task changes state, such as complete or error.</div>
</td><td class="summaryTableOwnerCol">TaskController</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#next()">next</a>():void</div>
<div class="summaryTableDescription">
   Checks to see if any task slots are available, if so then the next
   task in the queue is added.</div>
</td><td class="summaryTableOwnerCol">TaskController</td>
</tr>
</table>
</div>
<script type="text/javascript" language="javascript">
<!--
showHideInherited();
--></script>
<div class="MainContent">
<a name="propertyDetail"></a>
<div class="detailSectionHeader">Property detail</div>
<a name="activeTaskLimit"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">activeTaskLimit</td><td class="detailHeaderType">property</td>
</tr>
</table>
<div class="detailBody">
<code>activeTaskLimit:uint</code>&nbsp;&nbsp;[read-write]<p>
   Contains the number of tasks that can be run at the same time.  The defaulf value is 2 tasks.
    
   </p><span class="label">Implementation</span>
<br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;public function get activeTaskLimit():uint</code>
<br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;public function set activeTaskLimit(value:uint):void</code>
<br>
</div>
<a name="activeTasks"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">activeTasks</td><td class="detailHeaderType">property</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>protected var activeTasks:<a href="../datastructures/utils/HashTable.html">HashTable</a></code><p>
   Stores the active Tasks and TaskGroups that are have been started by the controller. 
   </p></div>
<a name="notReadyQueue"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">notReadyQueue</td><td class="detailHeaderType">property</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>protected var notReadyQueue:<a href="../datastructures/utils/HashTable.html">HashTable</a></code><p>
   Stores ITasks that returned false for the ready value when attempted to be started by the controller. 
   </p></div>
<a name="taskQueue"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">taskQueue</td><td class="detailHeaderType">property</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>protected var taskQueue:<a href="../datastructures/utils/PriorityQueue.html">PriorityQueue</a></code><p>
   Stores the current Tasks and TaskGroups within the TaskController. 
   </p></div>
<a name="constructorDetail"></a>
<div class="detailSectionHeader">Constructor detail</div>
<a name="TaskController()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">TaskController</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">constructor</td>
</tr>
</table>
<div class="detailBody">
<code>public function TaskController()</code><p>
   Constructor. 
   
   </p></div>
<a name="methodDetail"></a>
<div class="detailSectionHeader">Method detail</div>
<a name="addTask()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">addTask</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td>
</tr>
</table>
<div class="detailBody">
<code>public function addTask(task:<a href="interfaces/ITask.html">ITask</a>):void</code><p>
   When an ITask (task, task group, etc.) is ready to be added to the controller this
   method is called. addTask() puts the item at the end of the queue and then applies
   any overrides assigned by the ITask.  If the current queue contains overrides then
   the override conflict logic is applied to determine if the added item is kept and the
   existing conflicting task is removed or if the existing task is kept and the new one
   is discarded.
   
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">task</span>:<a href="interfaces/ITask.html">ITask</a></code> &mdash; The ITask to add to the controller.
   
   </td>
</tr>
</table>
</div>
<a name="applyOverrides()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">applyOverrides</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>protected function applyOverrides(newTask:<a href="interfaces/ITask.html">ITask</a>):Boolean</code><p>
   </p><p>
   Used to find and remove any tasks in the current
   queue that are overriden by a new task that has been
   added to the controller. This includes those tasks that are active.
   </p>
   <p>
   If the new task is selfOverriding two scenarios will play out.
   
   <ul>
    <li>If new task has same type and a different uid as a task in the queue or active queue the existing task is removed and canceled, the new task is then added to the queue.</li>
    <li>If new task has same type and the same uid as a queued or active task, the new task is ignored and not added to they system.</li>
   </ul>
   </p>
   <span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">newTask</span>:<a href="interfaces/ITask.html">ITask</a></code> &mdash; New Task to be added to queue
   
   </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Boolean</code> &mdash; Boolean True if newTasks overrides were processed,otherwise false
   </td>
</tr>
</table>
</div>
<a name="handleTaskEvent()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">handleTaskEvent</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>protected function handleTaskEvent(event:<a href="events/TaskEvent.html">TaskEvent</a>):void</code><p>
   Called when a task changes state, such as complete or error.  Handles
   unregistering event listening, checks to see if the queue was blocked and
   then calls next() to continue the process.
    
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">event</span>:<a href="events/TaskEvent.html">TaskEvent</a></code> &mdash; The TaskEvent dispatched from the watched ITask instance.
   
   </td>
</tr>
</table>
</div>
<a name="next()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">next</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>protected function next():void</code><p>
   Checks to see if any task slots are available, if so then the next
   task in the queue is added.  This method is called when tasks are added 
   or change state.  This method is protected to prevent developers from
   directly calling next() and instead letting the controller process the
   queue based on the defined logic. 
   
   </p></div>
<br>
<br>
<hr>
<br>
<p></p>
<center class="copyright"> 
</center>
</div>
</body>
</html>
<!-- -->
